package bible.test.util;

import java.util.HashMap;
import java.util.Map;


import bible.sunflower.util.http.HttpClientHelper;
import bible.sunflower.work.yinfeng.http.HttpClient4Hoyi;
import bible.sunflower.work.yinfeng.ui.CriteriaType;
import bible.sunflower.work.yinfeng.ui.Expr;
import bible.sunflower.work.yinfeng.ui.PageCond;

public class HttpClientTester {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		System.out.println("======START======");
		String cookieStr = "JSESSIONID=753B9DDD8BDBF16102F4E0F48ACC09E5";
		//queryServiceLog( cookieStr );
		//queryOpptunity( cookieStr );
		queryMenu( cookieStr );
		//queryVersion();
		System.out.println("======END======");
	}
	
	public static void queryOpptunity( String cookieStr ){
		Map<String, Object> paramMap = new HashMap<String,Object>();
		String requestUrl = "http://localhost:8080/default/com.hoyi.salesMgr.salesopp.salesoppcom.querySalesopp4emp.biz.ajax";
		/*
		CriteriaType criteria = new CriteriaType("com.hoyi.salesMgr.salesMgr.Opportunity");
		Expr subjectExpr = Expr.createLikeExpr("subject", Expr.LIKERULE_ALL, "");
		Expr custnameExpr = Expr.createLikeExpr("custname", Expr.LIKERULE_ALL, "");
		Expr timeExpr = Expr.createTimeExpr("createtime", "2000-01-01", "2013-06-06" );
		criteria.addExpr("subject", subjectExpr);
		criteria.addExpr("custname", custnameExpr);
		criteria.addExpr("time", timeExpr );
		paramMap.putAll( criteria.getRequestParam() );
		PageCond page = new PageCond();
		paramMap.putAll( page.getPageParam() );
		for(String key : paramMap.keySet() ){
			System.out.println( key + "=" + paramMap.get(key) );
		} */
		String data = HttpClient4Hoyi.invokeLogicflow(requestUrl, paramMap, cookieStr);
		if( data.indexOf("{\"exceptions\"") >= 0 ){
			System.out.println("===error===");
		}
	}
	
	public static void queryServiceLog( String cookieStr ){
		//String requestUrl = "http://192.168.2.118:8080/default/com.hoyi.serviceMgr.servicelog.servicelog.querySerlog4pad.biz.ajax";
		String requestUrl = "http://192.168.2.106:8080/default/salesMgr/creditcard/creditcardMgr.jsp";
		HttpClientHelper.sendHttpRequest(requestUrl, null, "", cookieStr);
	}
	
	public static void queryMenu( String cookieStr ){
		Map<String,Object> param = new HashMap<String,Object>();
    	//param.put("userId", "0004");
    	String requestUrl = "http://192.168.2.109:8080/default/com.hoyi.authority.AuthorityMgr.getCuserPadMenuAuth.biz.ajax";
    	HttpClient4Hoyi.invokeLogicflow(requestUrl, param, cookieStr);
	}
	
	public static void queryVersion(){
		String requestUrl = "http://localhost:8888/VToBank/pad/version.xml";
		HttpClientHelper.sendHttpRequest(requestUrl, null, "", "");
	}

}
